#ifndef _FENGINE_TYPE
#define _FENGINE_TYPE

#include "stdafx.h"
#include <string>

#define PI 3.14159265358979323846264338327950288
#define RADIANS_TO_DEGREES(rad) ((rad) * (180.0 / PI))
#define DEGREES_TO_RADIANS(deg) ((deg) / 180.0 * PI)

typedef D3DXVECTOR4 Vector4;
typedef D3DXVECTOR3 Vector3;
typedef D3DXVECTOR2 Vector2;

typedef D3DXMATRIX Matrix4;

typedef D3DXPLANE Plane;

enum NodeVisibility
{
	VISIBILITY_NONE = 0,
	VISIBILITY_PARTIAL,
	VISIBILITY_TOTAL,
};

struct FE_VERTEX
{
	Vector3 POSITION;
	Vector3 NORMAL;
	Vector3 TANGENT;
	Vector3 BINORMAL;
	Vector2 TEXCOORD;
};

struct FE_INSTANCE
{
	Vector3 POSITION;
	Vector3 NORMAL;
	Vector3 TANGENT;
	Vector3 BINORMAL;
	Vector2 TEXCOORD;

	Vector4 MATRIX_ROW_1;
	Vector4 MATRIX_ROW_2;
	Vector4 MATRIX_ROW_3;
	Vector4 MATRIX_ROW_4;
};

struct FE_BILLBOARD
{
	Vector3 POSITION;			// Position of the vertex
	Vector3 BILLBOARD_POSITION;	// World position of the quad the vertex is in
	Vector2 TEXCOORD;
	Vector2 WIND_FORCE;			// Represent the amplitude of movement or the grass billboard, and the offset of the movement
};

struct FE_IMPOSTOR
{
	Vector3 POSITION;			// Position of the vertex
	Vector3 IMPOSTOR_POSITION;	// World position of the quad the vertex is in
	Vector2 TEXCOORD;
	float	ROTATION;			// Rotation of the object 3D around the Y axis (in degree)
};

const D3DVERTEXELEMENT9 VertexDeclaration[] =
{
	{0,  0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
	{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
	{0, 24, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0},
	{0, 36, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0},
	{0, 48, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
	D3DDECL_END()
};

const D3DVERTEXELEMENT9 VertexDeclarationBatching[] =
{
	{0,  0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
	{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
	{0, 24, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0},
	{0, 36, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0},
	{0, 48, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},

	{1, 0,  D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1},
	{1, 16, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 2},
	{1, 32, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 3},
	{1, 48, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 4},

	D3DDECL_END()
};

const D3DVERTEXELEMENT9 VertexDeclarationBillboard[] =
{
	{0,  0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
	{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
	{0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1},
	{0, 32, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 2},
	D3DDECL_END()
};

const D3DVERTEXELEMENT9 VertexDeclarationImpostor[] =
{
	{0,  0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
	{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
	{0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1},
	{0, 32, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 2},
	D3DDECL_END()
};


#endif
